package model

import (
	"gorm.io/gorm"
)

type User struct { // 用户表
	ID         int          `gorm:"primaryKey;not null;auto_increment"`
	Name       string       `gorm:"size:20;comment:用户名"`
	Password   string       `gorm:"size:256;comment:密码"`
	Email      string       `gorm:"size:50;comment:邮箱"`
	IsActive   bool         `gorm:"default:false;comment:账号激活状态"` // false未激活，true激活
	IsAdmin    bool         `gorm:"default:false;comment:账号权限"`   // false非管理员，true管理员
	Address    []*Address   `gorm:"foreignKey:User_Id;references:ID"`
	OrderInfos []*OrderInfo `gorm:"foreignKey:User_Id;references:ID"`
	gorm.Model
}

type Address struct { // 地址表
	ID         int    `gorm:"primaryKey;not null;auto_increment"`
	Receiver   string `gorm:"size:20;comment:收件人"`
	Addr       string `gorm:"size:256;comment:收件地址"`
	Phone      string `gorm:"size:11;comment:联系电话"`
	Zipcode    string `gorm:"size:6;default:'000000';comment:邮政编码"`
	Isdefault  bool   `gorm:"default:false;comment:是否默认"` // false非默认，true默认
	User_Id    int
	OrderInfos []*OrderInfo `gorm:"foreignKey:Address_Id;references:ID"`
	gorm.Model
}
